package leetcode.每日一题;

import org.junit.Test;

import java.util.Arrays;

/**
 * @author ：zsy
 * @date ：Created 2022/12/4 6:32 PM
 * @description：
 */
public class 最接近目标价格的甜点成本 {
    @Test
    public void test() {

    }

    class Solution {
        public int closestCost(int[] baseCosts, int[] toppingCosts, int target) {
            return 0;
        }
    }

    /*
    class Solution {
        int res;
        public int closestCost(int[] baseCosts, int[] toppingCosts, int target) {
            res = Arrays.stream(baseCosts).min().getAsInt();
            for (int bc : baseCosts) {
                dfs(bc, 0, toppingCosts, target);
            }
            return res;
        }

        private void dfs(int curCost, int idx, int[] toppingCosts, int target) {
            if (curCost - target > Math.abs(res - target)) {
                return;
            } else if (Math.abs(curCost - target) <= Math.abs(res - target)) {
                if (Math.abs(curCost - target) < Math.abs(res - target)) {
                    res = curCost;
                } else {
                    res = Math.min(curCost, res);
                }
            }
            if (idx >= toppingCosts.length) return;
            // 两个配料
            dfs(curCost + toppingCosts[idx] * 2, idx + 1, toppingCosts, target);
            // 一个配料
            dfs(curCost + toppingCosts[idx], idx + 1, toppingCosts, target);
            // 不拿该配料
            dfs(curCost, idx + 1, toppingCosts, target);
        }
    }
    */
}
